{% extends 'base.html' %}

{% block title %}添加资产{% endblock %}

{% block content %}
<form class="layui-form" action="" method="post">
	<div class="layui-container">
	  <div class="layui-row">
	    <div class="layui-col-md5">
			  <div class="layui-form-item">
			    <label class="layui-form-label">IP</label>
			    <div class="layui-input-block">
			      <input type="text" name="ip" required  lay-verify="required" placeholder="请输入ip" value="" autocomplete="off" class="layui-input">
				    {% csrf_token %}
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md7"></div>
	  </div>

	  <div class="layui-row">
	    <div class="layui-col-md5">
			  <div class="layui-form-item">
			    <label class="layui-form-label">其他IP</label>
			    <div class="layui-input-block">
			      <input type="text" name="other_ip"  lay-verify="" placeholder="请输入其他ip" value="" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md7"></div>
	  </div>

	  <div class="layui-row">
	    <div class="layui-col-md5">
			  <div class="layui-form-item">
			    <label class="layui-form-label">主机名</label>
			    <div class="layui-input-block">
			      <input type="text" name="hostname"  lay-verify="" placeholder="请输入主机名" value="" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md7"></div>
	  </div>

	  <div class="layui-row">
	    <div class="layui-col-md5">
			  <div class="layui-form-item">
			    <label class="layui-form-label">ssh端口</label>
			    <div class="layui-input-block">
			      <input type="text" name="port" required  lay-verify="required|number" placeholder="请输入ssh端口" value="22" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md7"></div>
	  </div>

	  <div class="layui-row">
	    <div class="layui-col-md5">
			  <div class="layui-form-item">
			    <label class="layui-form-label">管理用户名</label>
			    <div class="layui-input-block">
			      <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" value="" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md7"></div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">密码</label>
	    <div class="layui-input-inline">
	      <input type="password" name="password" lay-verify="" placeholder="请输入密码" autocomplete="off" class="layui-input">
	    </div>
	    <div class="layui-form-mid layui-word-aux"></div>
	  </div>

		<div class="layui-form-item">
	    <label class="layui-form-label">所属主机组</label>
	    <div class="layui-input-inline">
	      <select name="group" lay-verify="required">
	        <option value="">请选择组</option>
		      {% for name in group %}
		        <option value="{{ name.id }}">{{ name.name }}</option>
		      {% endfor %}
	      </select>
	    </div>
		</div>

	  <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">备注</label>
	    <div class="layui-input-block">
	      <textarea name="comment" placeholder="请输入内容" class="layui-textarea"></textarea>
	    </div>
    </div>

		{% if error %}
		<div class="layui-row layui-col-space10">
      <div class="layui-col-md1">
	      <i class="layui-icon"></i>
      </div>
			<div class="layui-col-md4">
	      <i class="layui-icon" style="font-size: 30px; color: #FFB800;">&#xe69c;: {{ error }}</i>
			</div>
		</div>
		{% endif %}

	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</div>
</form>

<script>
//Demo
layui.use('form', function(){
  var form = layui.form;

  //监听提交
  form.on('submit(formDemo)', function(data){
{#    layer.msg(JSON.stringify(data.field));#}
    return true;
  });
});
</script>
{% endblock %}